package network.websocket;

import org.java_websocket.client.WebSocketClient;
import util.DialogHelper;

public class WSClientSender {

    public static void send(Object obj) {
        WebSocketClient client = WSClient.Instance.client.get();
        if (!client.isOpen()) {
            DialogHelper.showWaringDialog("正在与服务器链接...");
            return;
        }
        String msg = WSDtoConverter.buildWSDtoJson(obj);
        System.out.println("向服务器发送消息:\n" + msg);
        client.send(msg);
    }
}
